package com.szh.broadcastdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    private Button btnSend;
    private String STATIC_BROADCAST_ACTION = "com.szh.broadcastdemo";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btnSend = findViewById(R.id.btn_send);

        btnSend.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setAction(STATIC_BROADCAST_ACTION);//设置要发送的广播的频道号
                intent.putExtra("msg", "接收CustomStaticBroadcast成功");
                sendBroadcast(intent);
            }
        });
    }
}
